home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / FDsExample3.lha / Zeewolfscroll.asc < prev    next >
Text File  |  1999-01-21  |  4KB  |  89 lines

  1. ;Zeewolf Scroll Mildred Example.
  2. ;
  3. ;Programmed by : Mikkel Loekke, aka. FlameDuck.
  4. ;
  5. ;Please read the README file.
  6. ;
  7.  
  8. Fil$="RAM:M2P.ILBM"
  9.  
  10.  
  11. WBStartup
  12. NoCli
  13.  
  14. DEFTYPE.l
  15.  
  16. MCPU Processor                        ; Tell Mildred which CPU it should use.
  17. Mc2pCPUmode Processor                 ; Tell Mildred which CPU it should us for c2p.
  18.  
  19. MReserveBitmaps 1                     ; Tell Mildred that we're going to use 2 chunky bitmaps.
  20. MReservec2pWindows 1                  ; Tell it we only need one c2p display.
  21.  
  22. MBitmap 0,640,512                     ; This will contain our chunky buffer.
  23.  
  24. *pbb.l=AllocMem(640*512,#MEMF_PUBLIC) ; Get us a large block of any memory.
  25. If *pbb                               ; if we succeed
  26.   CludgeBitMap 0,640,512,8,*pbb       ; make it a bitmap (bitmaps can be in fast memory, aslong as we don't display them).
  27.   LoadBitMap 0,Fil$,0                 ; Load the logo.
  28.   MPlanar16ToBitmap 0,*pbb            ; convert it to a chunky bitmap
  29.   Free BitMap 0                       ; Free the bitmap structure. (We don't need it anymore
  30.   FreeMem *pbb,640*512                ; Free up our memory.
  31. Else End
  32. EndIf
  33.  
  34.  
  35. Mc2pWindow 0,320,256,640,320,256                 ; Define our c2p operation.
  36.  
  37. Dim bmppnt.l(1)                                  ; Create two bitmap pointers.
  38.  
  39. bmppnt(0)=AllocMem(320*256,#MEMF_CHIP)           ; Get some free CHIP memory.
  40. If bmppnt(0)                                     ; and if we succeed
  41.   CludgeBitMap 0,320,256,8,bmppnt(0)             ; make it a planar bitmap.
  42. Else End
  43. EndIf
  44.  
  45. bmppnt(1)=AllocMem(320*256,#MEMF_CHIP)           ; Get some more free CHIP memory.
  46. If bmppnt(1)                                     ; and if we succeed
  47.   CludgeBitMap 1,320,256,8,bmppnt(1)             ; make it our second planar bitmap. (For a double buffered display)
  48. Else End
  49. EndIf
  50.  
  51. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  52. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  53. scrtaglst(0)\ti_Data = 0            ; want.
  54. scrtaglst(1)\ti_Tag = #SA_Depth
  55. scrtaglst(1)\ti_Data = 8
  56. scrtaglst(2)\ti_Tag = #SA_Width
  57. scrtaglst(2)\ti_Data = 320
  58. scrtaglst(3)\ti_Tag = #SA_Height
  59. scrtaglst(3)\ti_Data = 256
  60. scrtaglst(4)\ti_Tag = #SA_BitMap
  61. scrtaglst(4)\ti_Data = Addr BitMap (0)
  62. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  63. scrtaglst(5)\ti_Data = 0
  64. scrtaglst(6)\ti_Tag = #SA_Draggable
  65. scrtaglst(6)\ti_Data = 0
  66. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  67.  
  68.  
  69. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen
  70. ShowPalette 0                               ; and show our palette.
  71.  
  72. x.w=160:y.w=128:xa.b=1:ya.b=1:act.b=0:rel.b=1 ; Initialize variables.
  73.  
  74. Repeat                                      ; Repeat our mainloop ....
  75.   ResetTimer
  76.   Mc2p 0,MBitmapPtr(x,y,0),bmppnt(rel)      ; Convert our chunky buffer to out the relative bitmap.
  77.  
  78.   If Timer <1 Then  WaitTOF_                ; Wait for refresh display, if the c2p took less than one frame.
  79.   ShowBitMap rel                            ; And show it.
  80.  
  81.   x+xa:y+ya                                 ; Jump arround on the display.
  82.   If x=319 OR x=1 Then xa=-xa               ; If we hit one edge of the bitmap, bounce the other way.
  83.   If y=255 OR y=1 Then ya=-ya               ; If we hit the top or bottom of the bitmap, bounce the other way.
  84.   If act=0 Then act=1:rel=0:Else act=0:rel=1 ; Swap relative and actual buffers (or bitmaps) the double buffering bit.
  85. Until RawStatus($45)                        ; .... Until we press Escape.
  86.  
  87. End                                         ; End our nice program.
  88.  
  89.